//==============================================================================
// LSLAligner.hh
//
//==============================================================================
//.......1.........2.........3.........4.........5.........6.........7.........8
//

#ifndef _LSL_ALIGNER
#define _LSL_ALIGNER

#include "LocalSTL.hh"
#include "Table.hh"
#include "Sequence.hh"

// KJD Move these inside the class. 

const int TOP=0x00000001;
const int LEFT=0x00000010;
const int DIAG=0x00000100;


//-----------------------------------------------------------------------------
// * LSLAligner
//-----------------------------------------------------------------------------
// Linear Space Local alignment
//
class LSLAligner{
public:

  void PrintScoreTable(int cols,int previous,int current);
  void PrintCTable(int cols,int previous,int current);


  LSLAligner(){
	 mMatchScore = 1;
	 mMismatchScore = -1;
	 mGapScore = -2;

	 mMaxScore = -99999;
	 mMaxRow = 0;
	 mMaxCol = 0;
  };

  Sequence mS,mQ;
  Sequence mAlignS,mAlignQ;
  
  int mRows,mCols;
  

  Table<int>  mScoreTable;
  Table<int>  mCTable;
  
  int 		  mMaxScore;
  int 		  mMaxRow;
  int 		  mMaxCol;
  
  // Score function parameters. 
  int mMatchScore;
  int mMismatchScore;
  int mGapScore;


  inline int 	Score(char A,char B){
	 int score;
	 if (A == B){
		score=mMatchScore;
	 }else{
		score=mMismatchScore;
	 }
	 return(score);
  }

  inline void Swap(int &a,int &b)
  {
	 int temp = a;
	 a = b;
	 b = temp;
  }
  
  void 	GetAlignment(Sequence &s,Sequence &q);
  void   HandleLimitingCase(int x1,int y1,int x2,int y2);
  void   GetAlignment(int x1,int y1,int x2,int y2);
  int    FindInterceptWithBestPath(int u,int x1,int y1,int x2,int y2);
};


#endif
